Fixed initial retrieval of the Jabber contact list for non-gtalk accounts. Fixes...
[adiumx.git] / Plugins / Gaim Service / Libgaim.framework / Versions / A / Headers / oscar.h
bloba9eaab1b635a29ac6c7839eca940a9eb59b94739
1 /*
2 * Gaim's oscar protocol plugin
3 * This file is the legal property of its developers.
4 * Please see the AUTHORS file distributed alongside this file.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Main libfaim header. Must be included in client for prototypes/macros.
24 * "come on, i turned a chick lesbian; i think this is the hackish equivalent"
25 * -- Josh Myer
29 #ifndef _OSCAR_H_
30 #define _OSCAR_H_
32 #include "circbuffer.h"
33 #include "debug.h"
34 #include "eventloop.h"
35 #include "internal.h"
36 #include "proxy.h"
38 #include <stdio.h>
39 #include <string.h>
40 #include <fcntl.h>
41 #include <sys/types.h>
42 #include <stdlib.h>
43 #include <stdarg.h>
44 #include <errno.h>
45 #include <time.h>
47 #ifndef _WIN32
48 #include <sys/time.h>
49 #include <unistd.h>
50 #include <netdb.h>
51 #include <netinet/in.h>
52 #include <sys/socket.h>
53 #else
54 #include "libc_interface.h"
55 #endif
57 typedef struct _ByteStream ByteStream;
58 typedef struct _ClientInfo ClientInfo;
59 typedef struct _FlapConnection FlapConnection;
60 typedef struct _FlapFrame FlapFrame;
61 typedef struct _IcbmArgsCh2 IcbmArgsCh2;
62 typedef struct _IcbmCookie IcbmCookie;
63 typedef struct _OscarData OscarData;
64 typedef struct _QueuedSnac QueuedSnac;
66 typedef guint32 aim_snacid_t;
68 #include "snactypes.h"
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
74 #define FAIM_SNAC_HASH_SIZE 16
77 * Current Maximum Length for Screen Names (not including NULL)
79 * Currently only names up to 16 characters can be registered
80 * however it is apparently legal for them to be larger.
82 #define MAXSNLEN 97
85 * Current Maximum Length for Instant Messages
87 * This was found basically by experiment, but not wholly
88 * accurate experiment. It should not be regarded
89 * as completely correct. But its a decent approximation.
91 * Note that although we can send this much, its impossible
92 * for WinAIM clients (up through the latest (4.0.1957)) to
93 * send any more than 1kb. Amaze all your windows friends
94 * with utterly oversized instant messages!
96 * TODO: the real limit is the total SNAC size at 8192. Fix this.
99 #define MAXMSGLEN 7987
102 * Maximum size of a Buddy Icon.
104 #define MAXICONLEN 7168
105 #define AIM_ICONIDENT "AVT1picture.id"
108 * Current Maximum Length for Chat Room Messages
110 * This is actually defined by the protocol to be
111 * dynamic, but I have yet to see due cause to
112 * define it dynamically here. Maybe later.
115 #define MAXCHATMSGLEN 512
118 * Maximum length for the password of an ICQ account
120 #define MAXICQPASSLEN 8
122 #define AIM_MD5_STRING "AOL Instant Messenger (SM)"
125 * Client info. Filled in by the client and passed in to
126 * aim_send_login(). The information ends up getting passed to OSCAR
127 * through the initial login command.
130 struct _ClientInfo
132 const char *clientstring;
133 guint16 clientid;
134 guint16 major;
135 guint16 minor;
136 guint16 point;
137 guint16 build;
138 guint32 distrib;
139 const char *country; /* two-letter abbrev */
140 const char *lang; /* two-letter abbrev */
143 /* Needs to be checked */
144 #define CLIENTINFO_AIM_3_5_1670 { \
145 "AOL Instant Messenger (SM), version 3.5.1670/WIN32", \
146 0x0004, \
147 0x0003, 0x0005, \
148 0x0000, 0x0686, \
149 0x0000002a, \
150 "us", "en", \
153 /* Needs to be checked */
154 /* Latest winaim without ssi */
155 #define CLIENTINFO_AIM_4_1_2010 { \
156 "AOL Instant Messenger (SM), version 4.1.2010/WIN32", \
157 0x0004, \
158 0x0004, 0x0001, \
159 0x0000, 0x07da, \
160 0x0000004b, \
161 "us", "en", \
164 /* Needs to be checked */
165 #define CLIENTINFO_AIM_4_3_2188 { \
166 "AOL Instant Messenger (SM), version 4.3.2188/WIN32", \
167 0x0109, \
168 0x0400, 0x0003, \
169 0x0000, 0x088c, \
170 0x00000086, \
171 "us", "en", \
174 /* Needs to be checked */
175 #define CLIENTINFO_AIM_4_8_2540 { \
176 "AOL Instant Messenger (SM), version 4.8.2540/WIN32", \
177 0x0109, \
178 0x0004, 0x0008, \
179 0x0000, 0x09ec, \
180 0x000000af, \
181 "us", "en", \
184 /* Needs to be checked */
185 #define CLIENTINFO_AIM_5_0_2938 { \
186 "AOL Instant Messenger, version 5.0.2938/WIN32", \
187 0x0109, \
188 0x0005, 0x0000, \
189 0x0000, 0x0b7a, \
190 0x00000000, \
191 "us", "en", \
194 #define CLIENTINFO_AIM_5_1_3036 { \
195 "AOL Instant Messenger, version 5.1.3036/WIN32", \
196 0x0109, \
197 0x0005, 0x0001, \
198 0x0000, 0x0bdc, \
199 0x000000d2, \
200 "us", "en", \
203 #define CLIENTINFO_AIM_5_5_3415 { \
204 "AOL Instant Messenger, version 5.5.3415/WIN32", \
205 0x0109, \
206 0x0005, 0x0005, \
207 0x0000, 0x0057, \
208 0x000000ef, \
209 "us", "en", \
212 #define CLIENTINFO_AIM_5_9_3702 { \
213 "AOL Instant Messenger, version 5.9.3702/WIN32", \
214 0x0109, \
215 0x0005, 0x0009, \
216 0x0000, 0x0e76, \
217 0x00000111, \
218 "us", "en", \
221 #define CLIENTINFO_ICHAT_1_0 { \
222 "Apple iChat", \
223 0x311a, \
224 0x0001, 0x0000, \
225 0x0000, 0x003c, \
226 0x000000c6, \
227 "us", "en", \
230 /* Needs to be checked */
231 #define CLIENTINFO_ICQ_4_65_3281 { \
232 "ICQ Inc. - Product of ICQ (TM) 2000b.4.65.1.3281.85", \
233 0x010a, \
234 0x0004, 0x0041, \
235 0x0001, 0x0cd1, \
236 0x00000055, \
237 "us", "en", \
240 /* Needs to be checked */
241 #define CLIENTINFO_ICQ_5_34_3728 { \
242 "ICQ Inc. - Product of ICQ (TM).2002a.5.34.1.3728.85", \
243 0x010a, \
244 0x0005, 0x0022, \
245 0x0001, 0x0e8f, \
246 0x00000055, \
247 "us", "en", \
250 #define CLIENTINFO_ICQ_5_45_3777 { \
251 "ICQ Inc. - Product of ICQ (TM).2003a.5.45.1.3777.85", \
252 0x010a, \
253 0x0005, 0x002d, \
254 0x0001, 0x0ec1, \
255 0x00000055, \
256 "us", "en", \
259 #define CLIENTINFO_ICQBASIC_14_3_1068 { \
260 "ICQBasic", \
261 0x010a, \
262 0x0014, 0x0003, \
263 0x0000, 0x042c, \
264 0x0000043d, \
265 "us", "en", \
268 #define CLIENTINFO_NETSCAPE_7_0_1 { \
269 "Netscape 2000 an approved user of AOL Instant Messenger (SM)", \
270 0x1d0d, \
271 0x0007, 0x0000, \
272 0x0001, 0x0000, \
273 0x00000058, \
274 "us", "en", \
277 #define CLIENTINFO_GAIM { \
278 "Gaim/" VERSION, \
279 0x0109, \
280 0x0005, 0x0001, \
281 0x0000, 0x0bdc, \
282 0x000000d2, \
283 "us", "en", \
286 #define CLIENTINFO_AIM_KNOWNGOOD CLIENTINFO_AIM_5_1_3036
287 #define CLIENTINFO_ICQ_KNOWNGOOD CLIENTINFO_ICQ_5_45_3777
289 typedef enum
291 OSCAR_DISCONNECT_DONE, /* not considered an error */
292 OSCAR_DISCONNECT_LOCAL_CLOSED, /* peer connections only, not considered an error */
293 OSCAR_DISCONNECT_REMOTE_CLOSED,
294 OSCAR_DISCONNECT_REMOTE_REFUSED, /* peer connections only */
295 OSCAR_DISCONNECT_LOST_CONNECTION,
296 OSCAR_DISCONNECT_INVALID_DATA,
297 OSCAR_DISCONNECT_COULD_NOT_CONNECT,
298 OSCAR_DISCONNECT_RETRYING /* peer connections only */
299 } OscarDisconnectReason;
301 typedef enum
303 OSCAR_CAPABILITY_BUDDYICON = 0x00000001,
304 OSCAR_CAPABILITY_TALK = 0x00000002,
305 OSCAR_CAPABILITY_DIRECTIM = 0x00000004,
306 OSCAR_CAPABILITY_CHAT = 0x00000008,
307 OSCAR_CAPABILITY_GETFILE = 0x00000010,
308 OSCAR_CAPABILITY_SENDFILE = 0x00000020,
309 OSCAR_CAPABILITY_GAMES = 0x00000040,
310 OSCAR_CAPABILITY_ADDINS = 0x00000080,
311 OSCAR_CAPABILITY_SENDBUDDYLIST = 0x00000100,
312 OSCAR_CAPABILITY_GAMES2 = 0x00000200,
313 OSCAR_CAPABILITY_ICQ_DIRECT = 0x00000400,
314 OSCAR_CAPABILITY_APINFO = 0x00000800,
315 OSCAR_CAPABILITY_ICQRTF = 0x00001000,
316 OSCAR_CAPABILITY_EMPTY = 0x00002000,
317 OSCAR_CAPABILITY_ICQSERVERRELAY = 0x00004000,
318 OSCAR_CAPABILITY_UNICODEOLD = 0x00008000,
319 OSCAR_CAPABILITY_TRILLIANCRYPT = 0x00010000,
320 OSCAR_CAPABILITY_UNICODE = 0x00020000,
321 OSCAR_CAPABILITY_INTEROPERATE = 0x00040000,
322 OSCAR_CAPABILITY_ICHAT = 0x00080000,
323 OSCAR_CAPABILITY_HIPTOP = 0x00100000,
324 OSCAR_CAPABILITY_SECUREIM = 0x00200000,
325 OSCAR_CAPABILITY_SMS = 0x00400000,
326 OSCAR_CAPABILITY_GENERICUNKNOWN = 0x00800000,
327 OSCAR_CAPABILITY_VIDEO = 0x01000000,
328 OSCAR_CAPABILITY_ICHATAV = 0x02000000,
329 OSCAR_CAPABILITY_LIVEVIDEO = 0x04000000,
330 OSCAR_CAPABILITY_CAMERA = 0x08000000,
331 OSCAR_CAPABILITY_LAST = 0x10000000
332 } OscarCapability;
335 * Byte Stream type. Sort of.
337 * Use of this type serves a couple purposes:
338 * - Buffer/buflen pairs are passed all around everywhere. This turns
339 * that into one value, as well as abstracting it slightly.
340 * - Through the abstraction, it is possible to enable bounds checking
341 * for robustness at the cost of performance. But a clean failure on
342 * weird packets is much better than a segfault.
343 * - I like having variables named "bs".
345 * Don't touch the insides of this struct. Or I'll have to kill you.
348 struct _ByteStream
350 guint8 *data;
351 guint32 len;
352 guint32 offset;
355 struct _QueuedSnac
357 guint16 family;
358 guint16 subtype;
359 FlapFrame *frame;
362 struct _FlapFrame
364 guint8 channel;
365 guint16 seqnum;
366 ByteStream data; /* payload stream */
369 struct _FlapConnection
371 OscarData *od; /**< Pointer to parent session. */
372 gboolean connected;
373 time_t lastactivity; /**< Time of last transmit. */
374 guint destroy_timeout;
375 OscarDisconnectReason disconnect_reason;
376 gchar *error_message;
378 /* A few variables that are only used when connecting */
379 GaimProxyConnectData *connect_data;
380 guint16 cookielen;
381 guint8 *cookie;
382 gpointer new_conn_data;
384 int fd;
385 guint8 header[6];
386 ssize_t header_received;
387 FlapFrame buffer_incoming;
388 GaimCircBuffer *buffer_outgoing;
389 guint watcher_incoming;
390 guint watcher_outgoing;
392 guint16 type;
393 guint16 subtype;
394 guint16 seqnum_out; /**< The sequence number of most recently sent packet. */
395 guint16 seqnum_in; /**< The sequence number of most recently received packet. */
396 GSList *groups;
397 GSList *rateclasses; /* Contains nodes of struct rateclass. */
399 GQueue *queued_snacs; /**< Contains QueuedSnacs. */
400 guint queued_timeout;
402 void *internal; /* internal conn-specific libfaim data */
405 struct _IcbmCookie
407 guchar cookie[8];
408 int type;
409 void *data;
410 time_t addtime;
411 struct _IcbmCookie *next;
414 #include "peer.h"
417 * AIM Session: The main client-data interface.
420 struct _OscarData
422 gboolean iconconnecting;
423 gboolean set_icon;
425 GSList *create_rooms;
427 gboolean conf;
428 gboolean reqemail;
429 gboolean setemail;
430 char *email;
431 gboolean setnick;
432 char *newsn;
433 gboolean chpass;
434 char *oldp;
435 char *newp;
437 GSList *oscar_chats;
438 GHashTable *buddyinfo;
439 GSList *requesticon;
441 gboolean killme;
442 gboolean icq;
443 guint icontimer;
444 guint getblisttimer;
445 guint getinfotimer;
446 gint timeoffset;
448 struct {
449 guint maxwatchers; /* max users who can watch you */
450 guint maxbuddies; /* max users you can watch */
451 guint maxgroups; /* max groups in server list */
452 guint maxpermits; /* max users on permit list */
453 guint maxdenies; /* max users on deny list */
454 guint maxsiglen; /* max size (bytes) of profile */
455 guint maxawaymsglen; /* max size (bytes) of posted away message */
456 } rights;
458 /* ---- Client Accessible ------------------------ */
460 /* Our screen name. */
461 /* TODO: Get rid of this and use gaim_account_get_username() everywhere? */
462 char sn[MAXSNLEN+1];
464 GaimConnection *gc;
466 /* ---- Internal Use Only ------------------------ */
468 void *modlistv;
471 * Outstanding snac handling
473 * TODO: Should these be per-connection? -mid
475 void *snac_hash[FAIM_SNAC_HASH_SIZE];
476 aim_snacid_t snacid_next;
479 * TODO: Data specific to a certain family should go into a
480 * hashtable and the core parts of libfaim shouldn't
481 * need to know about them.
484 IcbmCookie *msgcookies;
485 struct aim_icq_info *icq_info;
486 struct aim_authresp_info *authinfo;
487 struct aim_emailinfo *emailinfo;
489 struct {
490 struct aim_userinfo_s *userinfo;
491 struct userinfo_node *torequest;
492 struct userinfo_node *requested;
493 gboolean waiting_for_response;
494 } locate;
496 /* Server-stored information (ssi) */
497 struct {
498 gboolean received_data;
499 guint16 numitems;
500 struct aim_ssi_item *official;
501 struct aim_ssi_item *local;
502 struct aim_ssi_tmp *pending;
503 time_t timestamp;
504 gboolean waiting_for_ack;
505 gboolean in_transaction;
506 } ssi;
508 /** Contains pointers to handler functions for each family/subtype. */
509 GHashTable *handlerlist;
511 /** A linked list containing FlapConnections. */
512 GSList *oscar_connections;
514 /** A linked list containing PeerConnections. */
515 GSList *peer_connections;
518 /* Valid for calling aim_icq_setstatus() and for aim_userinfo_t->icqinfo.status */
519 #define AIM_ICQ_STATE_NORMAL 0x00000000
520 #define AIM_ICQ_STATE_AWAY 0x00000001
521 #define AIM_ICQ_STATE_DND 0x00000002
522 #define AIM_ICQ_STATE_OUT 0x00000004
523 #define AIM_ICQ_STATE_BUSY 0x00000010
524 #define AIM_ICQ_STATE_CHAT 0x00000020
525 #define AIM_ICQ_STATE_INVISIBLE 0x00000100
526 #define AIM_ICQ_STATE_WEBAWARE 0x00010000
527 #define AIM_ICQ_STATE_HIDEIP 0x00020000
528 #define AIM_ICQ_STATE_BIRTHDAY 0x00080000
529 #define AIM_ICQ_STATE_DIRECTDISABLED 0x00100000
530 #define AIM_ICQ_STATE_ICQHOMEPAGE 0x00200000
531 #define AIM_ICQ_STATE_DIRECTREQUIREAUTH 0x10000000
532 #define AIM_ICQ_STATE_DIRECTCONTACTLIST 0x20000000
534 typedef int (*aim_rxcallback_t)(OscarData *od, FlapConnection *conn, FlapFrame *frame, ...);
537 /* family_auth.c */
538 struct aim_clientrelease
540 char *name;
541 guint32 build;
542 char *url;
543 char *info;
546 struct aim_authresp_info
548 char *sn;
549 guint16 errorcode;
550 char *errorurl;
551 guint16 regstatus;
552 char *email;
553 char *bosip;
554 guint16 cookielen;
555 guint8 *cookie;
556 char *chpassurl;
557 struct aim_clientrelease latestrelease;
558 struct aim_clientrelease latestbeta;
561 /* Callback data for redirect. */
562 struct aim_redirect_data
564 guint16 group;
565 const char *ip;
566 guint16 cookielen;
567 const guint8 *cookie;
568 struct { /* group == SNAC_FAMILY_CHAT */
569 guint16 exchange;
570 const char *room;
571 guint16 instance;
572 } chat;
575 void aim_clientready(OscarData *od, FlapConnection *conn);
576 int aim_request_login(OscarData *od, FlapConnection *conn, const char *sn);
577 int aim_send_login(OscarData *, FlapConnection *, const char *, const char *, ClientInfo *, const char *key);
578 /* 0x000b */ int aim_auth_securid_send(OscarData *od, const char *securid);
580 void aim_cleansnacs(OscarData *, int maxage);
582 void oscar_data_addhandler(OscarData *od, guint16 family, guint16 subtype, aim_rxcallback_t newhandler, guint16 flags);
583 aim_rxcallback_t aim_callhandler(OscarData *od, guint16 family, guint16 subtype);
585 /* flap_connection.c */
586 FlapConnection *flap_connection_new(OscarData *, int type);
587 void flap_connection_close(OscarData *od, FlapConnection *conn);
588 void flap_connection_destroy(FlapConnection *conn, OscarDisconnectReason reason, const gchar *error_message);
589 void flap_connection_schedule_destroy(FlapConnection *conn, OscarDisconnectReason reason, const gchar *error_message);
590 FlapConnection *flap_connection_findbygroup(OscarData *od, guint16 group);
591 FlapConnection *flap_connection_getbytype(OscarData *, int type);
592 FlapConnection *flap_connection_getbytype_all(OscarData *, int type);
593 void flap_connection_recv_cb(gpointer data, gint source, GaimInputCondition cond);
594 void flap_connection_send(FlapConnection *conn, FlapFrame *frame);
595 void flap_connection_send_version(OscarData *od, FlapConnection *conn);
596 void flap_connection_send_version_with_cookie(OscarData *od, FlapConnection *conn, guint16 length, const guint8 *chipsahoy);
597 void flap_connection_send_snac(OscarData *od, FlapConnection *conn, guint16 family, const guint16 subtype, guint16 flags, aim_snacid_t snacid, ByteStream *data);
598 void flap_connection_send_keepalive(OscarData *od, FlapConnection *conn);
599 FlapFrame *flap_frame_new(OscarData *od, guint16 channel, int datalen);
601 OscarData *oscar_data_new(void);
602 void oscar_data_destroy(OscarData *);
604 /* misc.c */
605 #define AIM_VISIBILITYCHANGE_PERMITADD 0x05
606 #define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06
607 #define AIM_VISIBILITYCHANGE_DENYADD 0x07
608 #define AIM_VISIBILITYCHANGE_DENYREMOVE 0x08
610 #define AIM_PRIVFLAGS_ALLOWIDLE 0x01
611 #define AIM_PRIVFLAGS_ALLOWMEMBERSINCE 0x02
613 #define AIM_WARN_ANON 0x01
617 /* 0x0001 - family_oservice.c */
618 /* 0x0004 */ void aim_srv_requestnew(OscarData *od, guint16 serviceid);
619 /* 0x0006 */ void aim_srv_reqrates(OscarData *od, FlapConnection *conn);
620 /* 0x0008 */ void aim_srv_rates_addparam(OscarData *od, FlapConnection *conn);
621 /* 0x0009 */ void aim_srv_rates_delparam(OscarData *od, FlapConnection *conn);
622 /* 0x000c */ void aim_srv_sendpauseack(OscarData *od, FlapConnection *conn);
623 /* 0x000e */ void aim_srv_reqpersonalinfo(OscarData *od, FlapConnection *conn);
624 /* 0x0011 */ void aim_srv_setidle(OscarData *od, guint32 idletime);
625 /* 0x0014 */ void aim_srv_setprivacyflags(OscarData *od, FlapConnection *conn, guint32);
626 /* 0x0016 */ void aim_srv_nop(OscarData *od, FlapConnection *conn);
627 /* 0x0017 */ void aim_srv_setversions(OscarData *od, FlapConnection *conn);
628 /* 0x001e */ int aim_srv_setstatusmsg(OscarData *od, const char *msg);
629 /* 0x001e */ int aim_srv_setextstatus(OscarData *od, guint32 status);
632 void aim_bos_reqrights(OscarData *od, FlapConnection *conn);
633 int aim_bos_changevisibility(OscarData *od, FlapConnection *conn, int, const char *);
634 void aim_bos_setgroupperm(OscarData *od, FlapConnection *conn, guint32 mask);
638 #define AIM_CLIENTTYPE_UNKNOWN 0x0000
639 #define AIM_CLIENTTYPE_MC 0x0001
640 #define AIM_CLIENTTYPE_WINAIM 0x0002
641 #define AIM_CLIENTTYPE_WINAIM41 0x0003
642 #define AIM_CLIENTTYPE_AOL_TOC 0x0004
643 guint16 aim_im_fingerprint(const guint8 *msghdr, int len);
645 #define AIM_RATE_CODE_CHANGE 0x0001
646 #define AIM_RATE_CODE_WARNING 0x0002
647 #define AIM_RATE_CODE_LIMIT 0x0003
648 #define AIM_RATE_CODE_CLEARLIMIT 0x0004
649 void aim_ads_requestads(OscarData *od, FlapConnection *conn);
653 /* family_icbm.c */
654 #define AIM_OFT_SUBTYPE_SEND_FILE 0x0001
655 #define AIM_OFT_SUBTYPE_SEND_DIR 0x0002
656 #define AIM_OFT_SUBTYPE_GET_FILE 0x0011
657 #define AIM_OFT_SUBTYPE_GET_LIST 0x0012
659 #define AIM_TRANSFER_DENY_NOTSUPPORTED 0x0000
660 #define AIM_TRANSFER_DENY_DECLINE 0x0001
661 #define AIM_TRANSFER_DENY_NOTACCEPTING 0x0002
663 #define AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED 0x00000001
664 #define AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED 0x00000002
666 /* This is what the server will give you if you don't set them yourself. */
667 #define AIM_IMPARAM_DEFAULTS { \
668 0, \
669 AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \
670 512, /* !! Note how small this is. */ \
671 (99.9)*10, (99.9)*10, \
672 1000 /* !! And how large this is. */ \
675 /* This is what most AIM versions use. */
676 #define AIM_IMPARAM_REASONABLE { \
677 0, \
678 AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \
679 8000, \
680 (99.9)*10, (99.9)*10, \
684 struct aim_icbmparameters
686 guint16 maxchan;
687 guint32 flags; /* AIM_IMPARAM_FLAG_ */
688 guint16 maxmsglen; /* message size that you will accept */
689 guint16 maxsenderwarn; /* this and below are *10 (999=99.9%) */
690 guint16 maxrecverwarn;
691 guint32 minmsginterval; /* in milliseconds? */
695 * TODO: Should probably combine this with struct chat_connection.
697 struct aim_chat_roominfo
699 guint16 exchange;
700 char *name;
701 guint8 namelen;
702 guint16 instance;
705 struct chat_connection
707 char *name;
708 char *show; /* AOL did something funny to us */
709 guint16 exchange;
710 guint16 instance;
711 FlapConnection *conn;
712 int id;
713 GaimConnection *gc;
714 GaimConversation *conv;
715 int maxlen;
716 int maxvis;
720 * All this chat struct stuff should be in family_chat.c
722 void oscar_chat_destroy(struct chat_connection *cc);
724 #define AIM_IMFLAGS_AWAY 0x0001 /* mark as an autoreply */
725 #define AIM_IMFLAGS_ACK 0x0002 /* request a receipt notice */
726 #define AIM_IMFLAGS_BUDDYREQ 0x0010 /* buddy icon requested */
727 #define AIM_IMFLAGS_HASICON 0x0020 /* already has icon */
728 #define AIM_IMFLAGS_SUBENC_MACINTOSH 0x0040 /* damn that Steve Jobs! */
729 #define AIM_IMFLAGS_CUSTOMFEATURES 0x0080 /* features field present */
730 #define AIM_IMFLAGS_EXTDATA 0x0100
731 #define AIM_IMFLAGS_X 0x0200
732 #define AIM_IMFLAGS_MULTIPART 0x0400 /* ->mpmsg section valid */
733 #define AIM_IMFLAGS_OFFLINE 0x0800 /* send to offline user */
734 #define AIM_IMFLAGS_TYPINGNOT 0x1000 /* typing notification */
736 #define AIM_CHARSET_ASCII 0x0000
737 #define AIM_CHARSET_UNICODE 0x0002 /* UCS-2BE */
738 #define AIM_CHARSET_CUSTOM 0x0003
741 * Multipart message structures.
743 typedef struct aim_mpmsg_section_s
745 guint16 charset;
746 guint16 charsubset;
747 gchar *data;
748 guint16 datalen;
749 struct aim_mpmsg_section_s *next;
750 } aim_mpmsg_section_t;
752 typedef struct aim_mpmsg_s
754 unsigned int numparts;
755 aim_mpmsg_section_t *parts;
756 } aim_mpmsg_t;
758 int aim_mpmsg_init(OscarData *od, aim_mpmsg_t *mpm);
759 int aim_mpmsg_addraw(OscarData *od, aim_mpmsg_t *mpm, guint16 charset, guint16 charsubset, const gchar *data, guint16 datalen);
760 int aim_mpmsg_addascii(OscarData *od, aim_mpmsg_t *mpm, const char *ascii);
761 int aim_mpmsg_addunicode(OscarData *od, aim_mpmsg_t *mpm, const guint16 *unicode, guint16 unicodelen);
762 void aim_mpmsg_free(OscarData *od, aim_mpmsg_t *mpm);
765 * Arguments to aim_send_im_ext().
767 * This is really complicated. But immensely versatile.
770 struct aim_sendimext_args
773 /* These are _required_ */
774 const char *destsn;
775 guint32 flags; /* often 0 */
777 /* Only required if not using multipart messages */
778 const char *msg;
779 int msglen;
781 /* Required if ->msg is not provided */
782 aim_mpmsg_t *mpmsg;
784 /* Only used if AIM_IMFLAGS_HASICON is set */
785 guint32 iconlen;
786 time_t iconstamp;
787 guint32 iconsum;
789 /* Only used if AIM_IMFLAGS_CUSTOMFEATURES is set */
790 guint16 featureslen;
791 guint8 *features;
793 /* Only used if AIM_IMFLAGS_CUSTOMCHARSET is set and mpmsg not used */
794 guint16 charset;
795 guint16 charsubset;
799 * Arguments to aim_send_rtfmsg().
801 struct aim_sendrtfmsg_args
803 const char *destsn;
804 guint32 fgcolor;
805 guint32 bgcolor;
806 const char *rtfmsg; /* must be in RTF */
810 * This information is provided in the Incoming ICBM callback for
811 * Channel 1 ICBM's.
813 * Note that although CUSTOMFEATURES and CUSTOMCHARSET say they
814 * are optional, both are always set by the current libfaim code.
815 * That may or may not change in the future. It is mainly for
816 * consistency with aim_sendimext_args.
818 * Multipart messages require some explanation. If you want to use them,
819 * I suggest you read all the comments in family_icbm.c.
822 struct aim_incomingim_ch1_args
825 /* Always provided */
826 aim_mpmsg_t mpmsg;
827 guint32 icbmflags; /* some flags apply only to ->msg, not all mpmsg */
829 /* Only provided if message has a human-readable section */
830 gchar *msg;
831 int msglen;
833 /* Only provided if AIM_IMFLAGS_HASICON is set */
834 time_t iconstamp;
835 guint32 iconlen;
836 guint16 iconsum;
838 /* Only provided if AIM_IMFLAGS_CUSTOMFEATURES is set */
839 guint8 *features;
840 guint8 featureslen;
842 /* Only provided if AIM_IMFLAGS_EXTDATA is set */
843 guint8 extdatalen;
844 guint8 *extdata;
846 /* Only used if AIM_IMFLAGS_CUSTOMCHARSET is set */
847 guint16 charset;
848 guint16 charsubset;
851 /* Valid values for channel 2 args->status */
852 #define AIM_RENDEZVOUS_PROPOSE 0x0000
853 #define AIM_RENDEZVOUS_CANCEL 0x0001
854 #define AIM_RENDEZVOUS_CONNECTED 0x0002
856 struct _IcbmArgsCh2
858 guint16 status;
859 guchar cookie[8];
860 int type; /* One of the OSCAR_CAPABILITY_ constants */
861 const char *proxyip;
862 const char *clientip;
863 const char *verifiedip;
864 guint16 port;
865 gboolean use_proxy;
866 guint16 errorcode;
867 const char *msg; /* invite message or file description */
868 guint16 msglen;
869 const char *encoding;
870 const char *language;
871 guint16 requestnumber;
872 union {
873 struct {
874 guint32 checksum;
875 guint32 length;
876 time_t timestamp;
877 guint8 *icon;
878 } icon;
879 struct {
880 struct aim_chat_roominfo roominfo;
881 } chat;
882 struct {
883 guint16 msgtype;
884 guint32 fgcolor;
885 guint32 bgcolor;
886 const char *rtfmsg;
887 } rtfmsg;
888 struct {
889 guint16 subtype;
890 guint16 totfiles;
891 guint32 totsize;
892 char *filename;
893 } sendfile;
894 } info;
895 void *destructor; /* used internally only */
898 /* Valid values for channel 4 args->type */
899 #define AIM_ICQMSG_AUTHREQUEST 0x0006
900 #define AIM_ICQMSG_AUTHDENIED 0x0007
901 #define AIM_ICQMSG_AUTHGRANTED 0x0008
903 struct aim_incomingim_ch4_args
905 guint32 uin; /* Of the sender of the ICBM */
906 guint8 type;
907 guint8 flags;
908 gchar *msg; /* Reason for auth request, deny, or accept */
909 int msglen;
912 /* SNAC sending functions */
913 /* 0x0002 */ int aim_im_setparams(OscarData *od, struct aim_icbmparameters *params);
914 /* 0x0004 */ int aim_im_reqparams(OscarData *od);
915 /* 0x0006 */ int aim_im_sendch1_ext(OscarData *od, struct aim_sendimext_args *args);
916 /* 0x0006 */ int aim_im_sendch1(OscarData *, const char *destsn, guint16 flags, const char *msg);
917 /* 0x0006 */ int aim_im_sendch2_chatinvite(OscarData *od, const char *sn, const char *msg, guint16 exchange, const char *roomname, guint16 instance);
918 /* 0x0006 */ int aim_im_sendch2_icon(OscarData *od, const char *sn, const guint8 *icon, int iconlen, time_t stamp, guint16 iconsum);
919 /* 0x0006 */ int aim_im_sendch2_rtfmsg(OscarData *od, struct aim_sendrtfmsg_args *args);
921 /* 0x0006 */ void aim_im_sendch2_cancel(PeerConnection *peer_conn);
922 /* 0x0006 */ void aim_im_sendch2_connected(PeerConnection *peer_conn);
923 /* 0x0006 */ void aim_im_sendch2_odc_requestdirect(OscarData *od, guchar *cookie, const char *sn, const guint8 *ip, guint16 port, guint16 requestnumber);
924 /* 0x0006 */ void aim_im_sendch2_odc_requestproxy(OscarData *od, guchar *cookie, const char *sn, const guint8 *ip, guint16 pin, guint16 requestnumber);
925 /* 0x0006 */ void aim_im_sendch2_sendfile_requestdirect(OscarData *od, guchar *cookie, const char *sn, const guint8 *ip, guint16 port, guint16 requestnumber, const gchar *filename, guint32 size, guint16 numfiles);
926 /* 0x0006 */ void aim_im_sendch2_sendfile_requestproxy(OscarData *od, guchar *cookie, const char *sn, const guint8 *ip, guint16 pin, guint16 requestnumber, const gchar *filename, guint32 size, guint16 numfiles);
928 /* 0x0006 */ int aim_im_sendch2_geticqaway(OscarData *od, const char *sn, int type);
929 /* 0x0006 */ int aim_im_sendch4(OscarData *od, const char *sn, guint16 type, const char *message);
930 /* 0x0008 */ int aim_im_warn(OscarData *od, FlapConnection *conn, const char *destsn, guint32 flags);
931 /* 0x000b */ int aim_im_denytransfer(OscarData *od, const char *sn, const guchar *cookie, guint16 code);
932 /* 0x0014 */ int aim_im_sendmtn(OscarData *od, guint16 type1, const char *sn, guint16 type2);
933 void aim_icbm_makecookie(guchar* cookie);
934 gchar *oscar_encoding_extract(const char *encoding);
935 gchar *oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen);
936 gchar *gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, guint16 charset, guint16 charsubset, const gchar *data, gsize datalen);
939 /* 0x0002 - family_locate.c */
941 * AIM User Info, Standard Form.
943 #define AIM_FLAG_UNCONFIRMED 0x0001 /* "damned transients" */
944 #define AIM_FLAG_ADMINISTRATOR 0x0002
945 #define AIM_FLAG_AOL 0x0004
946 #define AIM_FLAG_OSCAR_PAY 0x0008
947 #define AIM_FLAG_FREE 0x0010
948 #define AIM_FLAG_AWAY 0x0020
949 #define AIM_FLAG_ICQ 0x0040
950 #define AIM_FLAG_WIRELESS 0x0080
951 #define AIM_FLAG_UNKNOWN100 0x0100
952 #define AIM_FLAG_UNKNOWN200 0x0200
953 #define AIM_FLAG_ACTIVEBUDDY 0x0400
954 #define AIM_FLAG_UNKNOWN800 0x0800
955 #define AIM_FLAG_ABINTERNAL 0x1000
956 #define AIM_FLAG_ALLUSERS 0x001f
958 #define AIM_USERINFO_PRESENT_FLAGS 0x00000001
959 #define AIM_USERINFO_PRESENT_MEMBERSINCE 0x00000002
960 #define AIM_USERINFO_PRESENT_ONLINESINCE 0x00000004
961 #define AIM_USERINFO_PRESENT_IDLE 0x00000008
962 #define AIM_USERINFO_PRESENT_ICQEXTSTATUS 0x00000010
963 #define AIM_USERINFO_PRESENT_ICQIPADDR 0x00000020
964 #define AIM_USERINFO_PRESENT_ICQDATA 0x00000040
965 #define AIM_USERINFO_PRESENT_CAPABILITIES 0x00000080
966 #define AIM_USERINFO_PRESENT_SESSIONLEN 0x00000100
967 #define AIM_USERINFO_PRESENT_CREATETIME 0x00000200
969 struct userinfo_node
971 char *sn;
972 struct userinfo_node *next;
975 typedef struct aim_userinfo_s
977 char *sn;
978 guint16 warnlevel; /* evil percent * 10 (999 = 99.9%) */
979 guint16 idletime; /* in seconds */
980 guint16 flags;
981 guint32 createtime; /* time_t */
982 guint32 membersince; /* time_t */
983 guint32 onlinesince; /* time_t */
984 guint32 sessionlen; /* in seconds */
985 guint32 capabilities;
986 struct {
987 guint32 status;
988 guint32 ipaddr;
989 guint8 crap[0x25]; /* until we figure it out... */
990 } icqinfo;
991 guint32 present;
993 guint8 iconcsumtype;
994 guint16 iconcsumlen;
995 guint8 *iconcsum;
997 char *info;
998 char *info_encoding;
999 guint16 info_len;
1001 char *status;
1002 char *status_encoding;
1003 guint16 status_len;
1005 char *away;
1006 char *away_encoding;
1007 guint16 away_len;
1009 struct aim_userinfo_s *next;
1010 } aim_userinfo_t;
1012 #define AIM_SENDMEMBLOCK_FLAG_ISREQUEST 0
1013 #define AIM_SENDMEMBLOCK_FLAG_ISHASH 1
1015 int aim_sendmemblock(OscarData *od, FlapConnection *conn, guint32 offset, guint32 len, const guint8 *buf, guint8 flag);
1017 struct aim_invite_priv
1019 char *sn;
1020 char *roomname;
1021 guint16 exchange;
1022 guint16 instance;
1025 #define AIM_COOKIETYPE_UNKNOWN 0x00
1026 #define AIM_COOKIETYPE_ICBM 0x01
1027 #define AIM_COOKIETYPE_ADS 0x02
1028 #define AIM_COOKIETYPE_BOS 0x03
1029 #define AIM_COOKIETYPE_IM 0x04
1030 #define AIM_COOKIETYPE_CHAT 0x05
1031 #define AIM_COOKIETYPE_CHATNAV 0x06
1032 #define AIM_COOKIETYPE_INVITE 0x07
1033 /* we'll move OFT up a bit to give breathing room. not like it really
1034 * matters. */
1035 #define AIM_COOKIETYPE_OFTIM 0x10
1036 #define AIM_COOKIETYPE_OFTGET 0x11
1037 #define AIM_COOKIETYPE_OFTSEND 0x12
1038 #define AIM_COOKIETYPE_OFTVOICE 0x13
1039 #define AIM_COOKIETYPE_OFTIMAGE 0x14
1040 #define AIM_COOKIETYPE_OFTICON 0x15
1042 aim_userinfo_t *aim_locate_finduserinfo(OscarData *od, const char *sn);
1043 void aim_locate_dorequest(OscarData *od);
1045 /* 0x0002 */ int aim_locate_reqrights(OscarData *od);
1046 /* 0x0004 */ int aim_locate_setcaps(OscarData *od, guint32 caps);
1047 /* 0x0004 */ int aim_locate_setprofile(OscarData *od, const char *profile_encoding, const gchar *profile, const int profile_len, const char *awaymsg_encoding, const gchar *awaymsg, const int awaymsg_len);
1048 /* 0x0005 */ int aim_locate_getinfo(OscarData *od, const char *, guint16);
1049 /* 0x0009 */ int aim_locate_setdirinfo(OscarData *od, const char *first, const char *middle, const char *last, const char *maiden, const char *nickname, const char *street, const char *city, const char *state, const char *zip, int country, guint16 privacy);
1050 /* 0x000b */ int aim_locate_000b(OscarData *od, const char *sn);
1051 /* 0x000f */ int aim_locate_setinterests(OscarData *od, const char *interest1, const char *interest2, const char *interest3, const char *interest4, const char *interest5, guint16 privacy);
1052 /* 0x0015 */ int aim_locate_getinfoshort(OscarData *od, const char *sn, guint32 flags);
1054 void aim_locate_requestuserinfo(OscarData *od, const char *sn);
1055 guint32 aim_locate_getcaps(OscarData *od, ByteStream *bs, int len);
1056 guint32 aim_locate_getcaps_short(OscarData *od, ByteStream *bs, int len);
1057 void aim_info_free(aim_userinfo_t *);
1058 int aim_info_extract(OscarData *od, ByteStream *bs, aim_userinfo_t *);
1059 int aim_putuserinfo(ByteStream *bs, aim_userinfo_t *info);
1063 /* 0x0003 - family_buddy.c */
1064 /* 0x0002 */ void aim_buddylist_reqrights(OscarData *, FlapConnection *);
1065 /* 0x0004 */ int aim_buddylist_set(OscarData *, FlapConnection *, const char *);
1066 /* 0x0004 */ int aim_buddylist_addbuddy(OscarData *, FlapConnection *, const char *);
1067 /* 0x0005 */ int aim_buddylist_removebuddy(OscarData *, FlapConnection *, const char *);
1071 /* 0x000a - family_userlookup.c */
1072 int aim_search_address(OscarData *, const char *);
1076 /* 0x000d - family_chatnav.c */
1077 /* 0x000e - family_chat.c */
1078 /* These apply to exchanges as well. */
1079 #define AIM_CHATROOM_FLAG_EVILABLE 0x0001
1080 #define AIM_CHATROOM_FLAG_NAV_ONLY 0x0002
1081 #define AIM_CHATROOM_FLAG_INSTANCING_ALLOWED 0x0004
1082 #define AIM_CHATROOM_FLAG_OCCUPANT_PEEK_ALLOWED 0x0008
1084 struct aim_chat_exchangeinfo
1086 guint16 number;
1087 guint16 flags;
1088 char *name;
1089 char *charset1;
1090 char *lang1;
1091 char *charset2;
1092 char *lang2;
1095 #define AIM_CHATFLAGS_NOREFLECT 0x0001
1096 #define AIM_CHATFLAGS_AWAY 0x0002
1097 int aim_chat_send_im(OscarData *od, FlapConnection *conn, guint16 flags, const gchar *msg, int msglen, const char *encoding, const char *language);
1098 int aim_chat_join(OscarData *od, guint16 exchange, const char *roomname, guint16 instance);
1099 int aim_chat_attachname(FlapConnection *conn, guint16 exchange, const char *roomname, guint16 instance);
1100 char *aim_chat_getname(FlapConnection *conn);
1101 FlapConnection *aim_chat_getconn(OscarData *, const char *name);
1103 void aim_chatnav_reqrights(OscarData *od, FlapConnection *conn);
1105 int aim_chatnav_createroom(OscarData *od, FlapConnection *conn, const char *name, guint16 exchange);
1106 int aim_chat_leaveroom(OscarData *od, const char *name);
1110 /* 0x000f - family_odir.c */
1111 struct aim_odir
1113 char *first;
1114 char *last;
1115 char *middle;
1116 char *maiden;
1117 char *email;
1118 char *country;
1119 char *state;
1120 char *city;
1121 char *sn;
1122 char *interest;
1123 char *nick;
1124 char *zip;
1125 char *region;
1126 char *address;
1127 struct aim_odir *next;
1130 int aim_odir_email(OscarData *, const char *, const char *);
1131 int aim_odir_name(OscarData *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *);
1132 int aim_odir_interest(OscarData *, const char *, const char *);
1136 /* 0x0010 - family_bart.c */
1137 int aim_bart_upload(OscarData *od, const guint8 *icon, guint16 iconlen);
1138 int aim_bart_request(OscarData *od, const char *sn, guint8 iconcsumtype, const guint8 *iconstr, guint16 iconstrlen);
1142 /* 0x0013 - family_feedbag.c */
1143 #define AIM_SSI_TYPE_BUDDY 0x0000
1144 #define AIM_SSI_TYPE_GROUP 0x0001
1145 #define AIM_SSI_TYPE_PERMIT 0x0002
1146 #define AIM_SSI_TYPE_DENY 0x0003
1147 #define AIM_SSI_TYPE_PDINFO 0x0004
1148 #define AIM_SSI_TYPE_PRESENCEPREFS 0x0005
1149 #define AIM_SSI_TYPE_ICONINFO 0x0014
1151 #define AIM_SSI_ACK_SUCCESS 0x0000
1152 #define AIM_SSI_ACK_ITEMNOTFOUND 0x0002
1153 #define AIM_SSI_ACK_IDNUMINUSE 0x000a
1154 #define AIM_SSI_ACK_ATMAX 0x000c
1155 #define AIM_SSI_ACK_INVALIDNAME 0x000d
1156 #define AIM_SSI_ACK_AUTHREQUIRED 0x000e
1158 /* These flags are set in the 0x00c9 TLV of SSI teyp 0x0005 */
1159 #define AIM_SSI_PRESENCE_FLAG_SHOWIDLE 0x00000400
1160 #define AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES 0x00020000
1162 struct aim_ssi_item
1164 char *name;
1165 guint16 gid;
1166 guint16 bid;
1167 guint16 type;
1168 struct aim_tlvlist_s *data;
1169 struct aim_ssi_item *next;
1172 struct aim_ssi_tmp
1174 guint16 action;
1175 guint16 ack;
1176 char *name;
1177 struct aim_ssi_item *item;
1178 struct aim_ssi_tmp *next;
1181 /* These build the actual SNACs and queue them to be sent */
1182 /* 0x0002 */ int aim_ssi_reqrights(OscarData *od);
1183 /* 0x0004 */ int aim_ssi_reqdata(OscarData *od);
1184 /* 0x0005 */ int aim_ssi_reqifchanged(OscarData *od, time_t localstamp, guint16 localrev);
1185 /* 0x0007 */ int aim_ssi_enable(OscarData *od);
1186 /* 0x0011 */ int aim_ssi_modbegin(OscarData *od);
1187 /* 0x0012 */ int aim_ssi_modend(OscarData *od);
1188 /* 0x0014 */ int aim_ssi_sendauth(OscarData *od, char *sn, char *msg);
1189 /* 0x0018 */ int aim_ssi_sendauthrequest(OscarData *od, char *sn, const char *msg);
1190 /* 0x001a */ int aim_ssi_sendauthreply(OscarData *od, char *sn, guint8 reply, const char *msg);
1192 /* Client functions for retrieving SSI data */
1193 struct aim_ssi_item *aim_ssi_itemlist_find(struct aim_ssi_item *list, guint16 gid, guint16 bid);
1194 struct aim_ssi_item *aim_ssi_itemlist_finditem(struct aim_ssi_item *list, const char *gn, const char *sn, guint16 type);
1195 struct aim_ssi_item *aim_ssi_itemlist_exists(struct aim_ssi_item *list, const char *sn);
1196 char *aim_ssi_itemlist_findparentname(struct aim_ssi_item *list, const char *sn);
1197 int aim_ssi_getpermdeny(struct aim_ssi_item *list);
1198 guint32 aim_ssi_getpresence(struct aim_ssi_item *list);
1199 char *aim_ssi_getalias(struct aim_ssi_item *list, const char *gn, const char *sn);
1200 char *aim_ssi_getcomment(struct aim_ssi_item *list, const char *gn, const char *sn);
1201 gboolean aim_ssi_waitingforauth(struct aim_ssi_item *list, const char *gn, const char *sn);
1203 /* Client functions for changing SSI data */
1204 int aim_ssi_addbuddy(OscarData *od, const char *name, const char *group, const char *alias, const char *comment, const char *smsnum, int needauth);
1205 int aim_ssi_addpermit(OscarData *od, const char *name);
1206 int aim_ssi_adddeny(OscarData *od, const char *name);
1207 int aim_ssi_delbuddy(OscarData *od, const char *name, const char *group);
1208 int aim_ssi_delpermit(OscarData *od, const char *name);
1209 int aim_ssi_deldeny(OscarData *od, const char *name);
1210 int aim_ssi_movebuddy(OscarData *od, const char *oldgn, const char *newgn, const char *sn);
1211 int aim_ssi_aliasbuddy(OscarData *od, const char *gn, const char *sn, const char *alias);
1212 int aim_ssi_editcomment(OscarData *od, const char *gn, const char *sn, const char *alias);
1213 int aim_ssi_rename_group(OscarData *od, const char *oldgn, const char *newgn);
1214 int aim_ssi_cleanlist(OscarData *od);
1215 int aim_ssi_deletelist(OscarData *od);
1216 int aim_ssi_setpermdeny(OscarData *od, guint8 permdeny, guint32 vismask);
1217 int aim_ssi_setpresence(OscarData *od, guint32 presence);
1218 int aim_ssi_seticon(OscarData *od, const guint8 *iconsum, guint16 iconsumlen);
1219 int aim_ssi_delicon(OscarData *od);
1223 /* 0x0015 - family_icq.c */
1224 #define AIM_ICQ_INFO_SIMPLE 0x001
1225 #define AIM_ICQ_INFO_SUMMARY 0x002
1226 #define AIM_ICQ_INFO_EMAIL 0x004
1227 #define AIM_ICQ_INFO_PERSONAL 0x008
1228 #define AIM_ICQ_INFO_ADDITIONAL 0x010
1229 #define AIM_ICQ_INFO_WORK 0x020
1230 #define AIM_ICQ_INFO_INTERESTS 0x040
1231 #define AIM_ICQ_INFO_ORGS 0x080
1232 #define AIM_ICQ_INFO_UNKNOWN 0x100
1233 #define AIM_ICQ_INFO_HAVEALL 0x1ff
1235 struct aim_icq_offlinemsg
1237 guint32 sender;
1238 guint16 year;
1239 guint8 month, day, hour, minute;
1240 guint8 type;
1241 guint8 flags;
1242 char *msg;
1243 int msglen;
1246 struct aim_icq_info
1248 guint16 reqid;
1250 /* simple */
1251 guint32 uin;
1253 /* general and "home" information (0x00c8) */
1254 char *nick;
1255 char *first;
1256 char *last;
1257 char *email;
1258 char *homecity;
1259 char *homestate;
1260 char *homephone;
1261 char *homefax;
1262 char *homeaddr;
1263 char *mobile;
1264 char *homezip;
1265 guint16 homecountry;
1266 /* guint8 timezone;
1267 guint8 hideemail; */
1269 /* personal (0x00dc) */
1270 guint8 age;
1271 guint8 unknown;
1272 guint8 gender;
1273 char *personalwebpage;
1274 guint16 birthyear;
1275 guint8 birthmonth;
1276 guint8 birthday;
1277 guint8 language1;
1278 guint8 language2;
1279 guint8 language3;
1281 /* work (0x00d2) */
1282 char *workcity;
1283 char *workstate;
1284 char *workphone;
1285 char *workfax;
1286 char *workaddr;
1287 char *workzip;
1288 guint16 workcountry;
1289 char *workcompany;
1290 char *workdivision;
1291 char *workposition;
1292 char *workwebpage;
1294 /* additional personal information (0x00e6) */
1295 char *info;
1297 /* email (0x00eb) */
1298 guint16 numaddresses;
1299 char **email2;
1301 /* we keep track of these in a linked list because we're 1337 */
1302 struct aim_icq_info *next;
1305 int aim_icq_reqofflinemsgs(OscarData *od);
1306 int aim_icq_ackofflinemsgs(OscarData *od);
1307 int aim_icq_setsecurity(OscarData *od, gboolean auth_required, gboolean webaware);
1308 int aim_icq_changepasswd(OscarData *od, const char *passwd);
1309 int aim_icq_getsimpleinfo(OscarData *od, const char *uin);
1310 int aim_icq_getalias(OscarData *od, const char *uin);
1311 int aim_icq_getallinfo(OscarData *od, const char *uin);
1315 /* 0x0017 - family_auth.c */
1316 void aim_sendcookie(OscarData *, FlapConnection *, const guint16 length, const guint8 *);
1317 int aim_admin_changepasswd(OscarData *, FlapConnection *, const char *newpw, const char *curpw);
1318 void aim_admin_reqconfirm(OscarData *od, FlapConnection *conn);
1319 int aim_admin_getinfo(OscarData *od, FlapConnection *conn, guint16 info);
1320 int aim_admin_setemail(OscarData *od, FlapConnection *conn, const char *newemail);
1321 int aim_admin_setnick(OscarData *od, FlapConnection *conn, const char *newnick);
1325 /* 0x0018 - family_alert.c */
1326 struct aim_emailinfo
1328 guint8 *cookie16;
1329 guint8 *cookie8;
1330 char *url;
1331 guint16 nummsgs;
1332 guint8 unread;
1333 char *domain;
1334 guint16 flag;
1335 struct aim_emailinfo *next;
1338 int aim_email_sendcookies(OscarData *od);
1339 int aim_email_activate(OscarData *od);
1343 /* tlv.c - TLV handling */
1345 /* TLV structure */
1346 typedef struct aim_tlv_s
1348 guint16 type;
1349 guint16 length;
1350 guint8 *value;
1351 } aim_tlv_t;
1353 /* TLV List structure */
1354 typedef struct aim_tlvlist_s
1356 aim_tlv_t *tlv;
1357 struct aim_tlvlist_s *next;
1358 } aim_tlvlist_t;
1360 /* TLV handling functions */
1361 char *aim_tlv_getvalue_as_string(aim_tlv_t *tlv);
1363 aim_tlv_t *aim_tlv_gettlv(aim_tlvlist_t *list, guint16 type, const int nth);
1364 int aim_tlv_getlength(aim_tlvlist_t *list, guint16 type, const int nth);
1365 char *aim_tlv_getstr(aim_tlvlist_t *list, const guint16 type, const int nth);
1366 guint8 aim_tlv_get8(aim_tlvlist_t *list, const guint16 type, const int nth);
1367 guint16 aim_tlv_get16(aim_tlvlist_t *list, const guint16 type, const int nth);
1368 guint32 aim_tlv_get32(aim_tlvlist_t *list, const guint16 type, const int nth);
1370 /* TLV list handling functions */
1371 aim_tlvlist_t *aim_tlvlist_read(ByteStream *bs);
1372 aim_tlvlist_t *aim_tlvlist_readnum(ByteStream *bs, guint16 num);
1373 aim_tlvlist_t *aim_tlvlist_readlen(ByteStream *bs, guint16 len);
1374 aim_tlvlist_t *aim_tlvlist_copy(aim_tlvlist_t *orig);
1376 int aim_tlvlist_count(aim_tlvlist_t **list);
1377 int aim_tlvlist_size(aim_tlvlist_t **list);
1378 int aim_tlvlist_cmp(aim_tlvlist_t *one, aim_tlvlist_t *two);
1379 int aim_tlvlist_write(ByteStream *bs, aim_tlvlist_t **list);
1380 void aim_tlvlist_free(aim_tlvlist_t **list);
1382 int aim_tlvlist_add_raw(aim_tlvlist_t **list, const guint16 type, const guint16 length, const guint8 *value);
1383 int aim_tlvlist_add_noval(aim_tlvlist_t **list, const guint16 type);
1384 int aim_tlvlist_add_8(aim_tlvlist_t **list, const guint16 type, const guint8 value);
1385 int aim_tlvlist_add_16(aim_tlvlist_t **list, const guint16 type, const guint16 value);
1386 int aim_tlvlist_add_32(aim_tlvlist_t **list, const guint16 type, const guint32 value);
1387 int aim_tlvlist_add_str(aim_tlvlist_t **list, const guint16 type, const char *value);
1388 int aim_tlvlist_add_caps(aim_tlvlist_t **list, const guint16 type, const guint32 caps);
1389 int aim_tlvlist_add_userinfo(aim_tlvlist_t **list, guint16 type, aim_userinfo_t *userinfo);
1390 int aim_tlvlist_add_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance);
1391 int aim_tlvlist_add_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvlist_t **tl);
1393 int aim_tlvlist_replace_raw(aim_tlvlist_t **list, const guint16 type, const guint16 lenth, const guint8 *value);
1394 int aim_tlvlist_replace_str(aim_tlvlist_t **list, const guint16 type, const char *str);
1395 int aim_tlvlist_replace_noval(aim_tlvlist_t **list, const guint16 type);
1396 int aim_tlvlist_replace_8(aim_tlvlist_t **list, const guint16 type, const guint8 value);
1397 int aim_tlvlist_replace_16(aim_tlvlist_t **list, const guint16 type, const guint16 value);
1398 int aim_tlvlist_replace_32(aim_tlvlist_t **list, const guint16 type, const guint32 value);
1400 void aim_tlvlist_remove(aim_tlvlist_t **list, const guint16 type);
1404 /* util.c */
1405 /* These are really ugly. You'd think this was LISP. I wish it was. */
1406 #define aimutil_put8(buf, data) ((*(buf) = (guint8)(data)&0xff),1)
1407 #define aimutil_get8(buf) ((*(buf))&0xff)
1408 #define aimutil_put16(buf, data) ( \
1409 (*(buf) = (guint8)((data)>>8)&0xff), \
1410 (*((buf)+1) = (guint8)(data)&0xff), \
1412 #define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff))
1413 #define aimutil_put32(buf, data) ( \
1414 (*((buf)) = (guint8)((data)>>24)&0xff), \
1415 (*((buf)+1) = (guint8)((data)>>16)&0xff), \
1416 (*((buf)+2) = (guint8)((data)>>8)&0xff), \
1417 (*((buf)+3) = (guint8)(data)&0xff), \
1419 #define aimutil_get32(buf) ((((*(buf))<<24)&0xff000000) + \
1420 (((*((buf)+1))<<16)&0x00ff0000) + \
1421 (((*((buf)+2))<< 8)&0x0000ff00) + \
1422 (((*((buf)+3) )&0x000000ff)))
1424 /* Little-endian versions (damn ICQ) */
1425 #define aimutil_putle8(buf, data) ( \
1426 (*(buf) = (guint8)(data) & 0xff), \
1428 #define aimutil_getle8(buf) ( \
1429 (*(buf)) & 0xff \
1431 #define aimutil_putle16(buf, data) ( \
1432 (*((buf)+0) = (guint8)((data) >> 0) & 0xff), \
1433 (*((buf)+1) = (guint8)((data) >> 8) & 0xff), \
1435 #define aimutil_getle16(buf) ( \
1436 (((*((buf)+0)) << 0) & 0x00ff) + \
1437 (((*((buf)+1)) << 8) & 0xff00) \
1439 #define aimutil_putle32(buf, data) ( \
1440 (*((buf)+0) = (guint8)((data) >> 0) & 0xff), \
1441 (*((buf)+1) = (guint8)((data) >> 8) & 0xff), \
1442 (*((buf)+2) = (guint8)((data) >> 16) & 0xff), \
1443 (*((buf)+3) = (guint8)((data) >> 24) & 0xff), \
1445 #define aimutil_getle32(buf) ( \
1446 (((*((buf)+0)) << 0) & 0x000000ff) + \
1447 (((*((buf)+1)) << 8) & 0x0000ff00) + \
1448 (((*((buf)+2)) << 16) & 0x00ff0000) + \
1449 (((*((buf)+3)) << 24) & 0xff000000))
1451 guint16 aimutil_iconsum(const guint8 *buf, int buflen);
1452 int aimutil_tokslen(char *toSearch, int theindex, char dl);
1453 int aimutil_itemcnt(char *toSearch, char dl);
1454 char *aimutil_itemindex(char *toSearch, int theindex, char dl);
1456 gboolean aim_snvalid(const char *sn);
1457 gboolean aim_sn_is_icq(const char *sn);
1458 gboolean aim_sn_is_sms(const char *sn);
1459 int aim_snlen(const char *sn);
1460 int aim_sncmp(const char *sn1, const char *sn2);
1465 typedef struct {
1466 guint16 family;
1467 guint16 subtype;
1468 guint16 flags;
1469 guint32 id;
1470 } aim_modsnac_t;
1472 #define AIM_MODULENAME_MAXLEN 16
1473 #define AIM_MODFLAG_MULTIFAMILY 0x0001
1474 typedef struct aim_module_s
1476 guint16 family;
1477 guint16 version;
1478 guint16 toolid;
1479 guint16 toolversion;
1480 guint16 flags;
1481 char name[AIM_MODULENAME_MAXLEN+1];
1482 int (*snachandler)(OscarData *od, FlapConnection *conn, struct aim_module_s *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs);
1483 void (*shutdown)(OscarData *od, struct aim_module_s *mod);
1484 void *priv;
1485 struct aim_module_s *next;
1486 } aim_module_t;
1488 int aim__registermodule(OscarData *od, int (*modfirst)(OscarData *, aim_module_t *));
1489 void aim__shutdownmodules(OscarData *od);
1490 aim_module_t *aim__findmodulebygroup(OscarData *od, guint16 group);
1491 aim_module_t *aim__findmodule(OscarData *od, const char *name);
1493 int admin_modfirst(OscarData *od, aim_module_t *mod);
1494 int buddylist_modfirst(OscarData *od, aim_module_t *mod);
1495 int bos_modfirst(OscarData *od, aim_module_t *mod);
1496 int search_modfirst(OscarData *od, aim_module_t *mod);
1497 int stats_modfirst(OscarData *od, aim_module_t *mod);
1498 int auth_modfirst(OscarData *od, aim_module_t *mod);
1499 int msg_modfirst(OscarData *od, aim_module_t *mod);
1500 int misc_modfirst(OscarData *od, aim_module_t *mod);
1501 int chatnav_modfirst(OscarData *od, aim_module_t *mod);
1502 int chat_modfirst(OscarData *od, aim_module_t *mod);
1503 int locate_modfirst(OscarData *od, aim_module_t *mod);
1504 int service_modfirst(OscarData *od, aim_module_t *mod);
1505 int invite_modfirst(OscarData *od, aim_module_t *mod);
1506 int translate_modfirst(OscarData *od, aim_module_t *mod);
1507 int popups_modfirst(OscarData *od, aim_module_t *mod);
1508 int adverts_modfirst(OscarData *od, aim_module_t *mod);
1509 int odir_modfirst(OscarData *od, aim_module_t *mod);
1510 int bart_modfirst(OscarData *od, aim_module_t *mod);
1511 int ssi_modfirst(OscarData *od, aim_module_t *mod);
1512 int icq_modfirst(OscarData *od, aim_module_t *mod);
1513 int email_modfirst(OscarData *od, aim_module_t *mod);
1515 void aim_genericreq_n(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype);
1516 void aim_genericreq_n_snacid(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype);
1517 void aim_genericreq_l(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype, guint32 *);
1518 void aim_genericreq_s(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype, guint16 *);
1520 /* bstream.c */
1521 int byte_stream_new(ByteStream *bs, guint32 len);
1522 int byte_stream_init(ByteStream *bs, guint8 *data, int len);
1523 int byte_stream_empty(ByteStream *bs);
1524 int byte_stream_curpos(ByteStream *bs);
1525 int byte_stream_setpos(ByteStream *bs, unsigned int off);
1526 void byte_stream_rewind(ByteStream *bs);
1527 int byte_stream_advance(ByteStream *bs, int n);
1528 guint8 byte_stream_get8(ByteStream *bs);
1529 guint16 byte_stream_get16(ByteStream *bs);
1530 guint32 byte_stream_get32(ByteStream *bs);
1531 guint8 byte_stream_getle8(ByteStream *bs);
1532 guint16 byte_stream_getle16(ByteStream *bs);
1533 guint32 byte_stream_getle32(ByteStream *bs);
1534 int byte_stream_getrawbuf(ByteStream *bs, guint8 *buf, int len);
1535 guint8 *byte_stream_getraw(ByteStream *bs, int len);
1536 char *byte_stream_getstr(ByteStream *bs, int len);
1537 int byte_stream_put8(ByteStream *bs, guint8 v);
1538 int byte_stream_put16(ByteStream *bs, guint16 v);
1539 int byte_stream_put32(ByteStream *bs, guint32 v);
1540 int byte_stream_putle8(ByteStream *bs, guint8 v);
1541 int byte_stream_putle16(ByteStream *bs, guint16 v);
1542 int byte_stream_putle32(ByteStream *bs, guint32 v);
1543 int byte_stream_putraw(ByteStream *bs, const guint8 *v, int len);
1544 int byte_stream_putstr(ByteStream *bs, const char *str);
1545 int byte_stream_putbs(ByteStream *bs, ByteStream *srcbs, int len);
1546 int byte_stream_putcaps(ByteStream *bs, guint32 caps);
1549 * Generic SNAC structure. Rarely if ever used.
1551 typedef struct aim_snac_s {
1552 aim_snacid_t id;
1553 guint16 family;
1554 guint16 type;
1555 guint16 flags;
1556 void *data;
1557 time_t issuetime;
1558 struct aim_snac_s *next;
1559 } aim_snac_t;
1561 /* snac.c */
1562 void aim_initsnachash(OscarData *od);
1563 aim_snacid_t aim_newsnac(OscarData *, aim_snac_t *newsnac);
1564 aim_snacid_t aim_cachesnac(OscarData *od, const guint16 family, const guint16 type, const guint16 flags, const void *data, const int datalen);
1565 aim_snac_t *aim_remsnac(OscarData *, aim_snacid_t id);
1566 int aim_putsnac(ByteStream *, guint16 family, guint16 type, guint16 flags, aim_snacid_t id);
1568 struct chatsnacinfo {
1569 guint16 exchange;
1570 char name[128];
1571 guint16 instance;
1574 struct rateclass {
1575 guint16 classid;
1576 guint32 windowsize;
1577 guint32 clear;
1578 guint32 alert;
1579 guint32 limit;
1580 guint32 disconnect;
1581 guint32 current;
1582 guint32 max;
1583 guint8 unknown[5]; /* only present in versions >= 3 */
1584 GHashTable *members; /* Key is family and subtype, value is TRUE. */
1586 struct timeval last; /**< The time when we last sent a SNAC of this rate class. */
1589 int aim_cachecookie(OscarData *od, IcbmCookie *cookie);
1590 IcbmCookie *aim_uncachecookie(OscarData *od, guint8 *cookie, int type);
1591 IcbmCookie *aim_mkcookie(guint8 *, int, void *);
1592 IcbmCookie *aim_checkcookie(OscarData *, const unsigned char *, const int);
1593 int aim_freecookie(OscarData *od, IcbmCookie *cookie);
1594 int aim_msgcookie_gettype(int type);
1595 int aim_cookie_free(OscarData *od, IcbmCookie *cookie);
1597 int aim_chat_readroominfo(ByteStream *bs, struct aim_chat_roominfo *outinfo);
1599 void flap_connection_destroy_chat(OscarData *od, FlapConnection *conn);
1601 #ifdef __cplusplus
1603 #endif
1605 #endif /* _OSCAR_H_ */